Expand GitHub style references in ChangeLog to URL#1547
Conversation
lib/rdoc/parser/changelog.rb
Outdated
| if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) | ||
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
There was a problem hiding this comment.
Could you add a comment with example substitutions for easy to understand? For example:
# base: https://github.com/ruby/ruby/
# Fix #15791 -> [Fix #15791](https://github.com/ruby/ruby/pull/15791)
# ...
lib/rdoc/parser/changelog.rb
Outdated
| if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) | ||
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
There was a problem hiding this comment.
Could you unify escape style to \K# or \K\#?
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | |
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
lib/rdoc/parser/changelog.rb
Outdated
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" |
There was a problem hiding this comment.
.../issues/#{N} is better than .../pull/#{N} because .../issues/#{N} works for both of issues and pull requests:
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" | |
| "[#$&](#{repo}issues/#{$1 || $2 || $3})" |
There was a problem hiding this comment.
I think /pull/ also works as well as /issues/, that is the conversion is bidirectional.
There was a problem hiding this comment.
I chose pull just because ruby/ruby is not using GitHub Issues.
lib/rdoc/parser/changelog.rb
Outdated
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" |
There was a problem hiding this comment.
Could you unify #{...} style?
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" | |
| "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" |
|
🚀 Preview deployment available at: https://51e1142a.rdoc-6cd.pages.dev (commit: 5e609fc) |
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" | ||
| end | ||
| contents.gsub!(%r[(?<![-\w#/@]|\]\[)([-\w]+/[-\w]+)(?:@(\h{8,40})|\#(\d+))(?![-\w#/@]|\]\[)]) do |
There was a problem hiding this comment.
Could you add an example comment here too?
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
For conciseness, omit URL expansion within ChangeLog files. Instead, RDoc now handles external commit references when converting ChangeLog to HTML. C.f., ruby/rdoc#1547.
For conciseness, omit URL expansion within ChangeLog files. Instead, RDoc now handles external commit references when converting ChangeLog to HTML. C.f., ruby/rdoc#1547.
Currently, ruby/ruby formats ChangeLog and expands such references to links.
But such links in ChangeLog that is a plain text does not make sense.
I think it is suitable to be done at conversion from ChangeLog to HTML